      IMPLICIT REAL*8 (A-H, L-Z)
      real*8 porb,md1,dt1,dt2,md2,mdcri,md3,m1dot,DC
      real*8 md(10000),dt(10000)
      open(1001,file='lps0.dat',status='unknown')      
      open(1002,file='lf2.dat',status='unknown')      
      md(0) = -4         
      dt(0) = 0
      
      do j = 1, 64
      md(j) = md(j-1) - 0.125
      dt2 = 0      
      rewind(1001)      
      do i=1,2880

      read(1001,*)porb,md1,dt1
c      mdc = 1.4*porb-8.56
      mdc = 1.4*porb-8.44      
      if(md1.lt.mdc)then
      md2 = 10**md1
      mdcri = 10**mdc
      porb = 10**porb

c      DC = 6.6d5*md2/porb**1.67
c      DC = 1.2d6*md2/porb**1.67
c      md1 = md1-log10(DC)
      md1 = 2*mdc-md1
c      md1 = md1-log10(1.0)
       dt1 = dt1*(md2/mdcri)**2
c       dt1 = dt1*DC
c       write(1,*) DC,md1,porb
c       dt1 = 0
c      dt1 = dt1*1.0 
      else
      md1 = md1
c      dt1 = 0
      dt1 = dt1 
      endif
      md3 = 10**md1
      m1dot = 3d-8+0.1*(md3-3d-8)        !..........

      md1 = min(md1,max(-7.52,log10(m1dot)))

      if(md1.le.md(j-1).and.md1.gt.md(j))then      
      dt2=dt2+dt1
      dt(j)=dt2+dt(j-1)
      endif
      enddo
c      lum = 0.47d26*10**md(j)
      lum = 0.84d26*10**md(j)
      write(1002,11) 1.0d20*lum,dt(j)*12d-10
      enddo               
11    format(2E12.2)
      end      
